package frsf.cidisi.exercise.modelo.search;

import java.util.List;

import frsf.cidisi.exercise.modelo.util.Coordenada;
import frsf.cidisi.exercise.modelo.util.Laberinto;
import frsf.cidisi.exercise.modelo.util.Salida;
import frsf.cidisi.faia.agent.Agent;
import frsf.cidisi.faia.agent.Perception;
import frsf.cidisi.faia.environment.Environment;

public class AgentePerception extends Perception {

    private Laberinto laberinto;
	private List<Coordenada> listaEntradas;
	private List<Salida> listaSalidas;
	private List<Coordenada> listaLlaves;
	
	//TODO: Setup Sensors
	private int percepcion; 

    public  AgentePerception() {
    	laberinto = null;
    	listaEntradas = null;
    	listaSalidas = null;
    	listaLlaves = null;
    }

    public AgentePerception(Agent agent, Environment environment) {
        super(agent, environment);
    }

    /**
     * This method is used to setup the perception.
     */
    @Override
    public void initPerception(Agent agentIn, Environment environmentIn) {
        
        Agente agent = (Agente) agentIn;
        Ambiente environment = (Ambiente) environmentIn;
        AmbienteEstado environmentState = environment.getEnvironmentState();
        
        this.setLaberinto(environmentState.getLaberinto());
        this.setListaEntradas(environmentState.getListaEntradas());
        this.setListaLlaves(environmentState.getListaLlaves());
        this.setListaSalidas(environmentState.getListaSalidas());
    }
    
    @Override
    public String toString() {
        StringBuffer str = new StringBuffer();
        str.append(System.getProperty("line.separator"));
        
		str.append("Laberinto: ").append(System.getProperty("line.separator"));
		str.append(getLaberinto()).append(System.getProperty("line.separator"));
		
		str.append("Entradas: ");
		for(Coordenada posicion : getListaEntradas()) {
			str.append(posicion).append(System.getProperty("line.separator"));
		}
		
		str.append("Llaves: ");
		for(Coordenada posicion : getListaLlaves()) {
			str.append(posicion).append(System.getProperty("line.separator"));
		}
		
		str.append("Salidas: ");
		for(Salida salida : getListaSalidas()) {
			str.append(salida).append(System.getProperty("line.separator"));
		}
		
        return str.toString();
    }

    // The following methods are agent-specific:
    //TODO: Complete this section with the agent-specific methods
	
     public int getPercepcion(){
        return percepcion;
     }
     public void setPercepcion(int percepcion){
        this.percepcion = percepcion;
     }

	public void setLaberinto(Laberinto laberinto) {
		this.laberinto = laberinto;
	}

	public Laberinto getLaberinto() {
		return laberinto;
	}

	public void setListaEntradas(List<Coordenada> listaEntradas) {
		this.listaEntradas = listaEntradas;
	}

	public List<Coordenada> getListaEntradas() {
		return listaEntradas;
	}

	public void setListaSalidas(List<Salida> listaSalidas) {
		this.listaSalidas = listaSalidas;
	}

	public List<Salida> getListaSalidas() {
		return listaSalidas;
	}

	public void setListaLlaves(List<Coordenada> listaLlaves) {
		this.listaLlaves = listaLlaves;
	}

	public List<Coordenada> getListaLlaves() {
		return listaLlaves;
	}

}
